import axios from 'axios'


export const getNews=(data)=>{
    return {
        type: 'GETNEWS',
        payload:data
    }
}


export const fetchNews=(params={page:1})=>{
    return (dispatch)=>{
        const url=`http://129.211.16.185:3000/news?_page=${params.page}&_limit=10`
        axios({
            url:url,
            method:"get"
        }).then(res=>{
            var obj={
                pageData:res.data,
                total:res.headers['x-total-count'],
                page:0
            }
            dispatch(getNews(obj));
        })
    }
    
}




